package com.hualan.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.mapper.SysUserMapper;
import com.hualan.pojo.SysUser;
import com.hualan.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public SysUser login(String phone, String password) {
        return sysUserMapper.login(phone, password);

    }

    @Override
    public int addUser(SysUser sysUser) {
        return sysUserMapper.insertUser(sysUser);
    }

    @Override
    public int updateUser(SysUser sysUser) {
        return sysUserMapper.updateUser(sysUser);
    }

    @Override
    public int deleteUserById(Integer id) {
        return sysUserMapper.deleteUserById(id);
    }

    @Override
    public int deleteUsersByIds(List<Integer> ids) {
        return sysUserMapper.deleteUsersByIds(ids);
    }

    public PageInfo<SysUser> getUserList(SysUser sysUser, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<SysUser> userList = sysUserMapper.selectUserList(sysUser, pageNum, pageSize);
        return new PageInfo<>(userList);
    }
}
